import { Component, createApp } from "vue";

export const mountComponent = (RootComponent: Component, data: object) => {
    // 传入一段vue模板，将其关在到body下
    const root = document.createElement("div")
    const close = () => document.body.removeChild(root)
    const app = createApp(RootComponent, { close, data })
    document.body.appendChild(root)
    return {
        instance: app.mount(root),
        unmount: close
    }
}